/*
 * @Date: 2025-06-13 10:50:10
 * @Auth: 463997479@qq.com
 * @LastEditors: 463997479@qq.com
 * @LastEditTime: 2025-07-31 17:56:50
 * @FilePath: \corpus\src\pages\corpusFile\EditUpload\index.tsx
 */
import UploadCorpus from '@/components/UploadCorpus';
import { Form, Input, Modal } from 'antd';
import type React from 'react';
import hooks from '../hooks';
const EditSystem: React.FC = () => {
  const { setEditFile, editFile, addKnowledge, form } = hooks.useContainer();
  const title = '新增文件';

  const handleSubmit = () => {
    form.validateFields().then((vals) => {
      const method = addKnowledge;
      method.run({
        ...vals,
      });
    });
  };
  return (
    <Modal
      width={600}
      title={title}
      open={editFile}
      onCancel={() => {
        setEditFile(false);
        form.resetFields();
      }}
      onOk={handleSubmit}
      confirmLoading={addKnowledge.loading}
    >
      <Form labelCol={{ span: 5 }} form={form}>
        <Form.Item name="id" hidden />
        <Form.Item label={'文件'} name="fileList" rules={[{ required: false }]}>
          <UploadCorpus
            action="/corpus/knowledgeFile/fileUpdate"
            handleChange={(val) => {
              if (val.file.response.success) {
                form.setFieldValue('fileName', val.file.response.data.fileName);
                form.setFieldValue('ossUrl', val.file.response.data.ossUrl);
              }
            }}
          />
        </Form.Item>

        {/* <Form.Item label={'语料库名称'} name="type" rules={[{ required: true, message: '请选择' }]}>
          <Select disabled style={{ width: '100% ' }} options={[]} />
        </Form.Item> */}
        <Form.Item label={'文件名称'} name="fileName" rules={[{ required: true }]}>
          <Input disabled placeholder="请输入" />
        </Form.Item>
        <Form.Item label={'文件oss地址'} name="ossUrl" rules={[{ required: true }]}>
          <Input disabled placeholder="请输入" />
        </Form.Item>
      </Form>
    </Modal>
  );
};

export default EditSystem;
